import types from '../../consts/actionTypes';

const selectWidget = widget => ({ type: types.widgets.SELECT_WIDGET, payload: widget });
const selectWidgets = widgets => ({ type: types.widgets.SELECT_WIDGETS, payload: widgets });
const selectWidgetsByIds = ids => ({ type: types.widgets.SELECT_WIDGETS_BY_IDS, payload: ids });
const removeWidget = widget => ({ type: types.widgets.REMOVE_WIDGET, payload: widget });
const toggleWidgetVisible = (widgetId, visible) => ({ type: types.widgets.TOGGLE_WIDGET_VISIBLE, payload: { widgetId, visible } });
const toggleWidgetsVisible = (widgetIds, visible) => ({ type: types.widgets.TOGGLE_WIDGETS_VISIBLE, payload: { widgetIds, visible } });
const updateWidget = widget => ({ type: types.widgets.UPDATE_WIDGET, payload: widget });
const updateWidgets = widgets => ({ type: types.widgets.UPDATE_WIDGETS, payload: widgets });
const addWidget = (widget, pageId) => ({ type: types.widgets.ADD_WIDGET, payload: { widget, pageId } });

export default {
    selectWidget,
    selectWidgets,
    selectWidgetsByIds,
    removeWidget,
    toggleWidgetVisible,
    toggleWidgetsVisible,
    updateWidget,
    updateWidgets,
    addWidget
};
